﻿using WeDonekRpc.Client;
using WeDonekRpc.Model;
using RpcStore.RemoteModel.Transmit;
using RpcStore.RemoteModel.Transmit.Model;
using Store.Gatewary.Modular.Interface;

namespace Store.Gatewary.Modular.Services
{
    internal class TransmitService : ITransmitService
    {
        public void Set (long id, TransmitConfig[] transmits)
        {
            new SetTransmit
            {
                Id = id,
                TransmitConfig = transmits
            }.Send();
        }

        public void Delete (long id)
        {
            new DeleteTransmit
            {
                Id = id
            }.Send();
        }

        public TransmitConfig[] Get (long id)
        {
            return new GetTransmits
            {
                Id = id
            }.Send();
        }

        public PagingResult<TransmitServer> Query (TransmitQuery query, IBasicPage paging)
        {
            TransmitServer[] list = new QueryTransmit
            {
                Query = query,
                Index = paging.Index,
                Size = paging.Size,
                NextId = paging.NextId,
                SortName = paging.SortName,
                IsDesc = paging.IsDesc
            }.Send(out int count);
            return new PagingResult<TransmitServer>(list, count);
        }

        public void Add (TransmitAdd datum)
        {
            new AddTransmit
            {
                Datum = datum
            }.Send();
        }
    }
}
